﻿// Decompiled with JetBrains decompiler
// Type: LayersParser.Objects.Dialog
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Collections.Generic;
using System.Xml.Linq;


namespace LayersParser.Objects;

public class Dialog : Common
{
  private bool isOlp;
  private string commandName;
  private string title;
  private string _description;

  public Dialog(XElement xElement)
  {
    this.Node = xElement;
    if (this.Node == null)
      return;
    this.title = (string) this.Node?.Attribute((XName) nameof (Title));
    this.Description = (string) this.Node?.Attribute((XName) nameof (Description));
  }

  public Dialog(bool isOlp)
  {
    this.Node = new XElement((XName) nameof (Dialog), new object[2]
    {
      (object) new XAttribute((XName) nameof (Title), (object) ""),
      (object) new XAttribute((XName) nameof (Description), (object) "")
    });
    if (isOlp)
      this.Node.Add((object) new XElement((XName) "OlpCommandRef", (object) new XElement((XName) "OlpCommand", (object) this.commandName)));
    else
      this.Node.Add((object) new XElement((XName) "RoboticParamRef"));
  }

  public Dialog(List<string> parameters)
  {
    this.Node = new XElement((XName) nameof (Dialog), new object[3]
    {
      (object) new XAttribute((XName) nameof (Title), (object) ""),
      (object) new XAttribute((XName) nameof (Description), (object) ""),
      (object) new XElement((XName) "RoboticParamRef")
    });
    foreach (string parameter in parameters)
      this.Node.Element((XName) "RoboticParamRef").Add((object) new XElement((XName) "Param", (object) parameter));
  }

  public bool IsOlp
  {
    get => this.isOlp;
    set => this.isOlp = value;
  }

  public string CommandName
  {
    get => this.commandName;
    set
    {
      this.commandName = value;
      this.Node.Element((XName) "OlpCommandRef").Element((XName) "OlpCommand").Value = this.commandName;
      this.Title = this.commandName;
    }
  }

  public string Title
  {
    get => this.title;
    set
    {
      this.title = value;
      if (this.Node.Attribute((XName) nameof (Title)) == null)
        this.Node.Add((object) new XAttribute((XName) nameof (Title), (object) ""));
      this.Node.Attribute((XName) nameof (Title)).Value = this.title;
    }
  }

  public string Description
  {
    get => this._description;
    set
    {
      this._description = value;
      if (value == null)
        return;
      if (this.Node.Attribute((XName) nameof (Description)) == null)
        this.Node.Add((object) new XAttribute((XName) nameof (Description), (object) ""));
      this.Node.Attribute((XName) nameof (Description)).Value = this._description;
    }
  }
}
